<script setup lang="ts">
import { useExample } from "./hook";
import { PureTableBar } from "@/components/RePureTableBar";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import add from "@iconify-icons/ri/add-fill";
import Delete from "@iconify-icons/ep/delete";
import EditPen from "@iconify-icons/ep/edit-pen";
import Search from "@iconify-icons/ep/search";
defineOptions({
  name: "filelist"
});
const form = { RoleType: { roleTypes: ["生命表", "重疾表"] } };
const { columns } = useExample();
</script>

<template>
  <div class="main">
    <PureTableBar title="生命/重疾表管理">
      <template #buttons>
        <el-form
          ref="formRef"
          :inline="true"
          :model="form"
          class="bg-bg_color w-[99/100] pl-8 pt-4"
        >
          <el-form-item label="类型：" prop="RoleType">
            <el-select
              v-model="form.RoleType"
              placeholder="请选择类型"
              clearable
              class="!w-[180px]"
            >
              <el-option
                v-for="item in form.RoleType.roleTypes"
                :key="item"
                :label="item"
                :value="item"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" :icon="useRenderIcon(Search)">
              搜索
            </el-button>
            <el-button type="primary" :icon="useRenderIcon(add)">
              新增
            </el-button>
          </el-form-item>
        </el-form>
      </template>
      <template v-slot="{ size, checkList }">
        <pure-table
          border
          align-whole="center"
          showOverflowTooltip
          table-layout="auto"
          :size="size"
          :columns="columns"
          :checkList="checkList"
          :paginationSmall="size === 'small' ? true : false"
          :header-cell-style="{
            background: 'var(--el-table-row-hover-bg-color)',
            color: 'var(--el-text-color-primary)'
          }"
        >
          <template #operation="">
            <el-button
              class="reset-margin"
              link
              type="primary"
              :size="size"
              :icon="useRenderIcon(EditPen)"
            >
              修改/查看
            </el-button>
            <el-popconfirm title="是否确认删除?">
              <template #reference>
                <el-button
                  class="reset-margin"
                  link
                  type="danger"
                  :size="size"
                  :icon="useRenderIcon(Delete)"
                >
                  删除
                </el-button>
              </template>
            </el-popconfirm>
          </template>
        </pure-table>
      </template>
    </PureTableBar>
  </div>
</template>

<style scoped lang="scss">
:deep(.el-dropdown-menu__item i) {
  margin: 0;
}
</style>
